﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Pulog
{
	// Note: For instructions on enabling IIS6 or IIS7 classic mode, 
	// visit http://go.microsoft.com/?LinkId=9394801

	public class MvcApplication : System.Web.HttpApplication
	{
		public static void RegisterRoutes(RouteCollection routes)
		{
			routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
			//routes.IgnoreRoute("{file}.jpg");
		   // routes.IgnoreRoute("attachment/{*pathInfo}");

			//routes.MapRoute(
			//    "Create",                                              // Route name
			//    "Posts/Add",                                      // URL with parameters
			//    new { controller = "Posts", action = "Add" }  // Parameter defaults
			//);

			//routes.MapRoute(
			//    "EditPost",                                              // Route name
			//    "Posts/Edit",                                      // URL with parameters
			//    new { controller = "Posts", action = "EditPostBySlug" }  // Parameter defaults
			//);

			//routes.MapRoute(
			//    "DeletePost",                                              // Route name
			//    "Posts/Delete",                                      // URL with parameters
			//    new { controller = "Posts", action = "DeletePostBySlug" }  // Parameter defaults
			//);

			//routes.MapRoute(
			//    "ShowPost",                                              // Route name
			//    "Posts/{slug}",                                      // URL with parameters
			//    new { controller = "Posts", action = "ShowSinglePostBySlug" }  // Parameter defaults
			//);
			

			routes.MapRoute(
				"Login",                                              // Route name
				"Login",                           // URL with parameters
				new { controller = "Account", action = "Login" }  // Parameter defaults
			);

			routes.MapRoute(
				"Register",                                              // Route name
				"Register",                           // URL with parameters
				new { controller = "Account", action = "Register" }  // Parameter defaults
			);

			routes.MapRoute(
				"Admin",                                              // Route name
				"Admin",                           // URL with parameters
				new { controller = "Admin", action = "Index" }  // Parameter defaults
            );
            routes.MapRoute(
                "Add Post",                                              // Route name
                "Admin/Posts/Add",                                      // URL with parameters
                new { controller = "Posts", action = "Add" }  // Parameter defaults
            );
            routes.MapRoute(
                "Edit Post",                                              // Route name
                "Admin/Posts/Edit",                                      // URL with parameters
                new { controller = "Posts", action = "Edit" }  // Parameter defaults
            );
			
			routes.MapRoute(
			    "ShowPostBySlug",                                              // Route name
			    "Posts/{slug}",                           // URL with parameters
			    new { controller ="Posts", action = "ShowSinglePostBySlug", slug = "" }  // Parameter defaults
			);

			routes.MapRoute(
			   "Category",                                              // Route name
			   "Category/{categoryName}",                           // URL with parameters
			   new { controller = "Posts", action = "Category", categoryName = "" }  // Parameter defaults
			);

			routes.MapRoute(
			   "Tags",                                              // Route name
			   "Tags/{tagName}",                           // URL with parameters
			   new { controller = "Posts", action = "Tags", tagName = "" }  // Parameter defaults
			);

			//routes.MapRoute(
			//    "Paging",                                              // Route name
			//    "Posts/Page/{page}",                           // URL with parameters
			//    new { controller = "Posts", action = "Index" }  // Parameter defaults
			//);


			//routes.MapRoute(
			//    "PagingIndex",                                              // Route name
			//    "{controller}/{action}/{pageIndex}",                           // URL with parameters
			//    new { controller = "Posts", action = "Index", pageIndex = "" }  // Parameter defaults
			//);

			routes.MapRoute(
				"Feed",                                              // Route name
				"Feed/",                              // URL with parameters
				new { controller = "Feed", action = "Index" }  // Parameter defaults
			);
			routes.MapRoute(
				"Search",                                              // Route name
				"Search/",                           // URL with parameters
				new { controller="Search", action="Index" }  // Parameter defaults
			);
			routes.MapRoute(
				"Buzz",                                              // Route name
				"Buzz/",                           // URL with parameters
				new { controller = "Buzz", action = "Index" }  // Parameter defaults
			);
			routes.MapRoute(
				"Default",                                              // Route name
				"{controller}/{action}/{id}",                           // URL with parameters
				new { controller = "Posts", action = "Page", id= "" }  // Parameter defaults
			);

			routes.MapRoute(
				"EditPaging",                                              // Route name
				"{controller}/{action}/Page/{page}",                           // URL with parameters
				new { controller = "Posts", action = "Edit", page = "" }  // Parameter defaults
			);

		}

		protected void Application_Start()
		{
			RegisterRoutes(RouteTable.Routes);
			//RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
		}
	}
}